﻿using Core.SystemLogs;
using FluentMigrator;

namespace Infrastructure.Migrations.SystemLogs;

[Migration(202510151012)]
public class CreateTableForSystemLog : ForwardOnlyMigration
{
    public override void Up()
    {
        Create
          .Table("SystemLogs")
          .WithColumn(nameof(SystemLog.Id)).AsInt32().PrimaryKey().Identity().WithColumnDescription("主键")
          .WithColumn("TenantId").AsString(int.MaxValue).Nullable().WithColumnDescription("租户标识")
          .WithColumn(nameof(SystemLog.Message)).AsString(int.MaxValue).Nullable().WithColumnDescription("日志消息")
          .WithColumn(nameof(SystemLog.MessageTemplate)).AsString(int.MaxValue).Nullable().WithColumnDescription("日志模板")
          .WithColumn(nameof(SystemLog.Level)).AsString(450).WithColumnDescription("日志等级")
          .WithColumn(nameof(SystemLog.TimeStamp)).AsDateTimeOffset().WithColumnDescription("时间")
          .WithColumn(nameof(SystemLog.Exception)).AsString(int.MaxValue).Nullable().WithColumnDescription("异常消息")
          .WithColumn(nameof(SystemLog.UserName)).AsString(100).Nullable().WithColumnDescription("用户名")
          .WithColumn(nameof(SystemLog.ClientIP)).AsString(256).Nullable().WithColumnDescription("客户端IP")
          .WithColumn(nameof(SystemLog.ClientAgent)).AsString(int.MaxValue).Nullable().WithColumnDescription("客户端代理")
          .WithColumn(nameof(SystemLog.Properties)).AsString(int.MaxValue).Nullable().WithColumnDescription("属性")
          .WithColumn(nameof(SystemLog.LogEvent)).AsString(int.MaxValue).Nullable().WithColumnDescription("日志事件");
    }
}
